<?php

namespace app\common\model;

use think\Model;
use app\common\model\Base;

class MemberAddress extends Base {
    //

    /**
     * @title 预处理
     */
    public function model_where($wheres = []) {

        if (request()->get('keyword'))
            $this->where('a.name|a.phone', 'like', '%' . request()->get('keyword') . '%');


        if (request()->get('province'))
            $this->where('a.province', '=', request()->get('province'));
        if (request()->get('city'))
            $this->where('a.city', '=', request()->get('city'));
        if (request()->get('county'))
            $this->where('a.county', '=', request()->get('county'));



        //
        $this->alias('a');

        $this->join('member m', 'm.id = a.member_id', 'LEFT');

        $this->order('id desc');

        $this->field('a.*,m.nickname');




        return $this;
    }

}
